

using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using Bookmvc.Db;
using Bookmvc.Repository;
using Bookmvc.Models;
using System.Linq;

namespace Bookmvc.Controllers
{
    public class Book:Controller
    {
        public IActionResult Index(string name){
            
               var db=new ERepository<Books>();

               var _tab=db.table.Where(x=>x.IsDeleted==false);

                var cc=_tab.FirstOrDefault();

           if (name!=null)
           {
                _tab=_tab.Where(x=>x.BookName.Contains(name));
              

           }



             return View(_tab.ToList());
        }
        

        public IActionResult save(zhongjianshang entiy){

            var _ef=new ERepository<Books>();

            var cc =new BookDbContext();
            _ef.Insert(
                new Books {

                    BookName=entiy.bookname,
                    ISBN=entiy.isbn,
                    Author=entiy.author,
                    Press=entiy.press,
                    Price=entiy.price
                }

            );

            return Ok();
        }
        public IActionResult Add(){



            return View();
        }

    }


}